<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateStudentResultsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('student_results', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('user_id')->comment('考生id')->index();
            $table->string('name')->comment('考生用户名')->index();
            $table->string('username')->comment('考生姓名')->index();
            $table->unsignedBigInteger('test_list_id')->comment('试卷id')->index();
            $table->unsignedBigInteger('examination_id')->comment('考试安排id')->index();
            $table->integer('type')->comment('试卷类型(1：正常试卷，2：练习试卷，3：闯关试卷，)')->index();
            $table->unsignedBigInteger('subject_id')->comment('科目id')->index();
            $table->string('user_section_ids')->comment('用户所属的部门')->index();
            $table->integer('fraction')->default(0)->comment('分数');
            $table->integer('success_num')->default(0)->comment('正确题数');
            $table->integer('error_num')->default(0)->comment('错误题数');
            $table->integer('already_num')->default(0)->comment('答题数');
            $table->integer('all_num')->comment('总题数');
            $table->integer('read_teacher_id')->comment('阅卷老师')->nullable();
            $table->dateTime('end_time')->nullable()->comment('交卷时间');
            $table->integer('timer')->nullable()->comment('考试用时');
            $table->json('content')->nullable()->comment('考试内容');
            $table->integer('submit_type')->default(0)->comment('交卷类型 (0:正常交卷，1:作废 2:强退，3:强制交卷4:未交卷)');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('student_results');
    }
}
